package com.tianhui.consignortwofei.mvp.ui.activity.deliverGoods.edit;

import android.text.TextUtils;

import com.tianhui.consignortwofei.mvp.model.enty.SourcePathInfo;
import com.tianhui.consignortwofei.mvp.ui.activity.deliverGoods.normal.DeliverGoodsStepOneActivity;

/**
 * @author fgs
 * @date 2021/3/8
 * @description
 **/
public class EditDeliveryGoodsStepOneActivity extends DeliverGoodsStepOneActivity {

    @Override
    public void initView() {
        super.initView();

        //取单地
        SourcePathInfo pathInfo;
        pathInfo = new SourcePathInfo();
        pathInfo.placeprovince = mGoodsInfo.placeprovince;
        pathInfo.placecity = mGoodsInfo.placecity;
        pathInfo.placecounty = mGoodsInfo.placecounty;
        pathInfo.placedetails = mGoodsInfo.placedetails;
        pathInfo.address = getPlaceAddress(pathInfo);
        pathInfo.placeusername = mGoodsInfo.placeusername;
        pathInfo.placetel = mGoodsInfo.placetel;
        setSelectPathHistory(mPlaceClickItemView,mPlaceAddressInputItemView,mPlaceUserInputItemView,mPlacePhoneInputItemView,pathInfo);

        //装货地
        pathInfo = new SourcePathInfo();
        pathInfo.placeprovince = mGoodsInfo.deliverprovince;
        pathInfo.placecity = mGoodsInfo.delivercity;
        pathInfo.placecounty = mGoodsInfo.delivercounty;
        pathInfo.placedetails = mGoodsInfo.deliverdetails;
        pathInfo.address = getPlaceAddress(pathInfo);
        pathInfo.placeusername = mGoodsInfo.deliverusername;
        pathInfo.placetel = mGoodsInfo.delivertel;
        setSelectPathHistory(mDeliverClickItemView,mDeliverAddressInputItemView,mDeliverUserInputItemView,mDeliverPhoneInputItemView,pathInfo);

        //交货地
        pathInfo = new SourcePathInfo();
        pathInfo.placeprovince = mGoodsInfo.destinationprovince;
        pathInfo.placecity = mGoodsInfo.destinationcity;
        pathInfo.placecounty = mGoodsInfo.destinationcounty;
        pathInfo.address = getPlaceAddress(pathInfo);
        pathInfo.placeusername = mGoodsInfo.destinationusername;
        pathInfo.placetel = mGoodsInfo.destinationtel;
        setSelectPathHistory(mDestinationClickItemView,mDestinationAddressInputItemView,mDestinationUserInputItemView,mDestinationPhoneInputItemView,pathInfo);
    }

    private String getPlaceAddress(SourcePathInfo pathInfo) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(pathInfo.placeprovince);
        if (!TextUtils.isEmpty(pathInfo.placecity)) {
            stringBuilder.append("，");
            stringBuilder.append(pathInfo.placecity);
        }
        if (!TextUtils.isEmpty(pathInfo.placecounty)) {
            stringBuilder.append("，");
            stringBuilder.append(pathInfo.placecounty);
        }
        return stringBuilder.toString();

    }

    @Override
    protected void openNextActivity() {
        openNextStepActivity(EditDeliverGoodsStepTwoActivity.class);
    }
}
